//
//  CompanyInfoDetailViewController.m
//  CYWFrame
//
//  Created by 于顺燊 on 2018/10/24.
//  Copyright © 2018年 Macx. All rights reserved.
//

#import "CompanyInfoDetailViewController.h"

@interface CompanyInfoDetailViewController ()
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *contentViewWidth;
@property (weak, nonatomic) IBOutlet UILabel *companyName;
@property (weak, nonatomic) IBOutlet UIImageView *companyLogo;
@property (weak, nonatomic) IBOutlet UILabel *companyStatus;
@property (weak, nonatomic) IBOutlet UILabel *size;
@property (weak, nonatomic) IBOutlet UILabel *field;
@property (weak, nonatomic) IBOutlet UIButton *address;
@property (weak, nonatomic) IBOutlet UILabel *intro;
@property (weak, nonatomic) IBOutlet UILabel *advantage;
@property (weak, nonatomic) IBOutlet UIImageView *teamImage;
@property (weak, nonatomic) IBOutlet UILabel *bossInfo;
@property (strong, nonatomic) IBOutletCollection(UILabel) NSArray *labelNeedToAdjustSize;

@end

@implementation CompanyInfoDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
	self.contentViewWidth.constant = SCREEN_WIDTH;
	self.navigationItem.title = @"公司介绍";
	[self getCompanyInfo];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)adjustUI {
	
}

- (void)getCompanyInfo
{
	NSDictionary *dict = @{@"company_id":self.companyId};
	[[NetworkTool sharedTool] requestWithName:@"获取企业信息" URLString:APIQueryCompany parameters:dict method:@"POST" callBack:^(id responseObject) {
		NSDictionary *dict = responseObject[@"data"];
		if ([dict isKindOfClass:[NSDictionary class]]) {
			CompanyInfo *model = [[CompanyInfo alloc] init];
			[model setValuesForKeysWithDictionary:dict];
			self.model = model;
			[self assignValue];
		}
		else
		{
			NSLog(@"is not a dict");
		}
		
	}];
}

- (void)assignValue {
	[self.companyLogo sd_setImageWithURL:[NSURL URLWithString:self.model.logo] placeholderImage:IMAGE(@"placeHolder")];
	self.companyName.text = self.model.title;
	self.companyStatus.text = self.model.development;
	self.size.text = self.model.company_size;
	self.field.text = self.model.industry_field;
	[self.address setTitle:self.model.address forState:UIControlStateNormal];
	self.intro.text = self.model.desc;
	self.advantage.text = self.model.advantage;
	[self.teamImage sd_setImageWithURL:[NSURL URLWithString:self.model.team_img] placeholderImage:IMAGE(@"placeHolder")];
	self.teamImage.contentMode = UIViewContentModeScaleAspectFit;
	self.bossInfo.text = self.model.boss;
	for (UILabel *label in self.labelNeedToAdjustSize) {
		[label sizeToFit];
	}
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
